package gameStates.gui;

import com.jme.input.InputHandler;

import gameStates.absGamesStates.AbsIngameState;
import gameStates.absGamesStates.gui.AbsChatState;
import gameStates.passes.AbsPassManagerState;
import input.ChatKeyInput;
import interfaces.hud.chat.ChatInputWindow;
import interfaces.hud.chat.ChatType;

public class ChatState extends AbsChatState {
		
	private ChatInputWindow chatWindow;
	private InputHandler inputHandler;
	
	public ChatState(AbsPassManagerState passManagerState, AbsIngameState ingameState) {
		super("chat", passManagerState, true, ingameState);
		
		chatWindow = new ChatInputWindow(this);
		addWidget(chatWindow);
		
		inputHandler = new ChatKeyInput(rootNode, this);
		
//		putAtEnd();
	}
	
	public void clearChatInput() { chatWindow.clearInputField(); }
	
	@Override
	public void setChatType(ChatType type) {
		chatWindow.setChatType(type);
	}
	
	@Override
	public void submitChatText() {
		assert(isActive());
		chatWindow.submitText();
	}
	
	@Override
	public void update(float time) {
		inputHandler.update(time);
		
		super.update(time);
	}
}